
function doStuff()  
{  
  setTimeout(continueExecution, 80);//暂停80毫秒
}  
 
//抖动完成,还原弹出层位置
function continueExecution()  
{  
   var mainPanel = $(".dialog-container:visible");
	var width = mainPanel.width();
	var height = mainPanel.height();
	var left = mainPanel.offset().left;
	var top = mainPanel.offset().top;
    mainPanel.width(width-4).height(height-4).css("top",top + 2).css("left",left + 2);
} 

//点击mask底部蒙版，弹出层进行抖动
$(".dialog-mask").click(function(){
    var mainPanel = $(".dialog-container:visible");
	var width = mainPanel.width();
	var height = mainPanel.height();
	var left = mainPanel.offset().left;
	var top = mainPanel.offset().top;
	mainPanel.width(width+4).height(height+4).css("top",top - 2).css("left",left - 2);
	doStuff();
});

//隐藏弹出框
function dialog_hide(){
	$(".dialog-mask").hide();
	$(".dialog-container").hide();
}
//隐藏yellowPanel
function clear_dialog(){
	$(".dialog-mask").hide();
	$(".confirm-dialog").hide();
	$(".confirm-dialog-zg").hide();
}

//弹出框入口
var Dialog={ 
    simple:function(html,callback) { //简单对话框
    	var sure_index = 1;
    	$(".dialog-mask").show();
		$("#dialog-simple").show();
		//$("#dialog_type").val("simple");
		$(".dialog-container:visible").find(".dialog-container-content").text(html);
		$("#dialog-simple").find(".dialog-btn-sure").click(function(){
			if(sure_index != 1) return false;
			++ sure_index;
			dialog_hide();
			if( callback ) callback(true);
		});
	}, 
	confirm:function(html,callback) { //确认对话框
		var sure_index = 1;
		$(".dialog-mask").show();
		$("#dialog-confirm").show();
		//$("#dialog_type").val("confirm");
		$("#dialog-confirm").find(".dialog-container-content").text(html);
		$("#dialog-confirm").find(".dialog-btn-sure").click(function(){
			if(sure_index != 1) return false;
			++ sure_index;
			dialog_hide();
			if( callback ) callback(true);
		});
		$("#dialog-confirm").find(".dialog-btn-cancel").click(function(){
			if(sure_index != 1) return false;
			++ sure_index;
			dialog_hide();
			//if( callback ) callback(false);
		});
	},
	htmlPanel:function(html,bname){//html简单对话框
		var sure_index = 1;
		$(".dialog-mask").show();
		$("#dialog-htmlPanel").show();
		//$("#dialog_type").val("htmlPanel");
		$("#dialog-htmlPanel").find(".dialog-container-content-html").html(html);
		$("#dialog-htmlPanel").find(".dialog-btn-sure").text(bname);//按钮内容

	},
	htmlconfirmPanel:function(html,callback,bname) { //html确认对话框
		var sure_index = 1;
		$(".dialog-mask").show();
		$("#dialog-htmlconfirmPanel").show();
		//$("#dialog_type").val("confirm");
		$("#dialog-htmlconfirmPanel").find(".dialog-container-content-html").html(html);
		$("#dialog-htmlconfirmPanel").find(".dialog-btn-sure").text(bname);//按钮内容
		$("#dialog-htmlconfirmPanel").find(".dialog-btn-sure").click(function(){
			if(sure_index != 1) return false;
			++ sure_index;
			dialog_hide();
			if( callback ) callback(true);
		});
		$("#dialog-htmlconfirmPanel").find(".dialog-btn-cancel").click(function(){
			if(sure_index != 1) return false;
			++ sure_index;
			dialog_hide();
			//if( callback ) callback(false);
		});
	},
	yellowPanel:function(icon,text,bname,callback){
		var sure_index = 1;
		$(".dialog-mask").show();
		//$("#dialog-yellowPanel").show();
		$(".confirm-dialog").show();
		$(".confirm-dialog-zg").show();
		$(".join-"+icon).show();
		$(".join-"+icon+"-title").html(text).show();
		if(bname) $("#dialog-sbtn2").html(bname);
		$("#dialog-sbtn2").click(function(){
			if(sure_index != 1) return false;
			++ sure_index;
			clear_dialog();
			if( callback ) callback(true);
		});
	}
} 





